# request库的使用
# http://www.codeceo.com/artic

import requests

#cookies 

resp = requests.get('http://httpbin.org/cookies/set?psw=123456789')
print(resp.text)

url = 'http://httpbin.org/cookies'
resp = requests.get(url)
print('resp.cookies=',resp.cookies) #获取cookies 如果存在的话

cookies = {"username":'kfjoy'}
url = 'http://httpbin.org/cookies'
resp = requests.get(url,cookies=cookies) #设置cookie

#seesion 会话

s = requests.session()
s.get('http://httpbin.org/cookies/set?psw=123456789') #设置会话
r = s.get('http://httpbin.org/cookies')
print(r.text)